package com.xjrsoft.module.customerTwo.barin.t_intelligent_manufacturing_solutions.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.page.ConventPage;
import java.util.List;
import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.customerTwo.barin.t_intelligent_manufacturing_solutions.dto.TIntelligentManufacturingSolutionsDto;
import com.xjrsoft.module.customerTwo.barin.t_intelligent_manufacturing_solutions.dto.SaveTIntelligentManufacturingSolutionsFormDataDto;
import com.xjrsoft.module.customerTwo.barin.t_intelligent_manufacturing_solutions.vo.TIntelligentManufacturingSolutionsVo;
import com.xjrsoft.module.customerTwo.barin.t_intelligent_manufacturing_solutions.vo.TIntelligentManufacturingSolutionsListVo;
import com.xjrsoft.module.customerTwo.barin.t_intelligent_manufacturing_solutions.dto.TIntelligentManufacturingSolutionsListDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;

import org.springframework.web.bind.annotation.*;
import com.xjrsoft.module.customerTwo.barin.t_intelligent_manufacturing_solutions.entity.TIntelligentManufacturingSolutions;
import com.xjrsoft.module.customerTwo.barin.t_intelligent_manufacturing_solutions.vo.TIntelligentManufacturingSolutionsVo;
import com.xjrsoft.module.customerTwo.barin.t_intelligent_manufacturing_solutions.service.ITIntelligentManufacturingSolutionsService;

/**
 *  控制器
 *
 * @author dongxinhang
 * @since 2024-11-18
 */
@RestController
@AllArgsConstructor
@RequestMapping("/t_intelligent_manufacturing_solutions")
@Api(value = "智造解决方案", tags = "智造解决方案接口")
public class TIntelligentManufacturingSolutionsController {


	private final ITIntelligentManufacturingSolutionsService tIntelligentManufacturingSolutionsService;


	/**
	 * 详情 
	 */
	@GetMapping("/{id}")
	@ApiOperation(value = "详情", notes = "传入tIntelligentManufacturingSolutions")
	public Response<TIntelligentManufacturingSolutionsVo> getFormData(@PathVariable String id) {
		// 主表数据
		TIntelligentManufacturingSolutions tIntelligentManufacturingSolutions = tIntelligentManufacturingSolutionsService.getById(id);
		TIntelligentManufacturingSolutionsVo tIntelligentManufacturingSolutionsVo = BeanUtil.copy(tIntelligentManufacturingSolutions, TIntelligentManufacturingSolutionsVo.class);
		return Response.ok(tIntelligentManufacturingSolutionsVo);
	}

	/**
	 * 自定义分页 
	 */
	@GetMapping
	@ApiOperation(value = "分页", notes = "传入tIntelligentManufacturingSolutions")
		public Response<PageOutput<TIntelligentManufacturingSolutionsListVo>> getPageList(TIntelligentManufacturingSolutionsListDto listDto) {
		IPage<TIntelligentManufacturingSolutions> page = tIntelligentManufacturingSolutionsService.getPageList(listDto);
		List<TIntelligentManufacturingSolutionsListVo> records = BeanUtil.copyList(page.getRecords(), TIntelligentManufacturingSolutionsListVo.class);
		return Response.ok(ConventPage.getPageOutput(page.getTotal(), records));
	}

	/**
	 * 新增 
	 */
	@PostMapping
	@ApiOperation(value = "新增", notes = "传入tIntelligentManufacturingSolutions")
	public Response save(@RequestBody SaveTIntelligentManufacturingSolutionsFormDataDto formDto) {
		TIntelligentManufacturingSolutionsDto tIntelligentManufacturingSolutionsDto = formDto.getTIntelligentManufacturingSolutionsDto();
		TIntelligentManufacturingSolutions tIntelligentManufacturingSolutions = BeanUtil.copy(tIntelligentManufacturingSolutionsDto, TIntelligentManufacturingSolutions.class);
		boolean isSuccess = tIntelligentManufacturingSolutionsService.addTIntelligentManufacturingSolutions(tIntelligentManufacturingSolutions);
		return Response.status(isSuccess);
	}

	/**
	 * 修改 
	 */
	@PutMapping("/{id}")
	@ApiOperation(value = "修改", notes = "传入tIntelligentManufacturingSolutions")
	public Response update(@PathVariable String id, @RequestBody SaveTIntelligentManufacturingSolutionsFormDataDto formDto) {
		TIntelligentManufacturingSolutionsDto tIntelligentManufacturingSolutionsDto = formDto.getTIntelligentManufacturingSolutionsDto();
		TIntelligentManufacturingSolutions tIntelligentManufacturingSolutions = BeanUtil.copy(tIntelligentManufacturingSolutionsDto, TIntelligentManufacturingSolutions.class);
		return Response.status(tIntelligentManufacturingSolutionsService.updateTIntelligentManufacturingSolutions(id, tIntelligentManufacturingSolutions));
	}



	/**
	 * 删除 
	 */
	@DeleteMapping("/{ids}")
	@ApiOperation(value = "删除", notes = "传入ids")
	public Response remove(@ApiParam(value = "主键集合", required = true) @PathVariable String ids) {
		return Response.status(tIntelligentManufacturingSolutionsService.delete(ids));
	}


}
